package cn.labbook.bluetooth.service.impl;

import cn.labbook.bluetooth.common.TokenManager;
import cn.labbook.bluetooth.entity.ServerPayStatistics;
import cn.labbook.bluetooth.entity.ServicePay;
import cn.labbook.bluetooth.mapper.ServicePayMapper;
import cn.labbook.bluetooth.service.IServicePayService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lonzy
 * @since 2019-03-26
 */
@Service
public class ServicePayServiceImpl extends ServiceImpl<ServicePayMapper, ServicePay> implements IServicePayService {

    @Override
    public String[] servicePayStatisticsForArray() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String format = sdf.format(new Date());
        Map<String, Double> stringDoubleMap = this.baseMapper.servicePayStatistics(format);
        String[] i = new String[12];
        if(stringDoubleMap!=null){
            i[0] = stringDoubleMap.get("januaryNum").toString();
            i[1] = stringDoubleMap.get("februaryNum").toString();
            i[2] = stringDoubleMap.get("marchNum").toString();
            i[3] = stringDoubleMap.get("aprilNum").toString();
            i[4] = stringDoubleMap.get("mayNum").toString();
            i[5] = stringDoubleMap.get("juneNum").toString();
            i[6] = stringDoubleMap.get("julyNum").toString();
            i[7] = stringDoubleMap.get("augustNum").toString();
            i[8] = stringDoubleMap.get("septemberNum").toString();
            i[9] = stringDoubleMap.get("octoberNum").toString();
            i[10] = stringDoubleMap.get("novemberNum").toString();
            i[11] = stringDoubleMap.get("decemberNum").toString();
        }

        return i;
    }

    @Override
    public String[] servicePayStatisticsByAdminForArray() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String format = sdf.format(new Date());
        String adminId = TokenManager.getToken().getAdminId();
        Map<String, Double> stringDoubleMap = this.baseMapper.servicePayStatisticsByAdmin(format,adminId);
        String[] i = new String[12];
        if(null != stringDoubleMap){
            i[0] = stringDoubleMap.get("januaryNum").toString();
            i[1] = stringDoubleMap.get("februaryNum").toString();
            i[2] = stringDoubleMap.get("marchNum").toString();
            i[3] = stringDoubleMap.get("aprilNum").toString();
            i[4] = stringDoubleMap.get("mayNum").toString();
            i[5] = stringDoubleMap.get("juneNum").toString();
            i[6] = stringDoubleMap.get("julyNum").toString();
            i[7] = stringDoubleMap.get("augustNum").toString();
            i[8] = stringDoubleMap.get("septemberNum").toString();
            i[9] = stringDoubleMap.get("octoberNum").toString();
            i[10] = stringDoubleMap.get("novemberNum").toString();
            i[11] = stringDoubleMap.get("decemberNum").toString();
        }
        return i;
    }
    @Override
    public List<ServerPayStatistics> servicePayStatistics(String time) {
        Map<String, Double> stringDoubleMap = this.baseMapper.servicePayStatistics(time);
        return null;
    }

    @Override
    public List<ServerPayStatistics> servicePayStatisticsByAdmin(String time, String adminId) {
        return null;
    }

    @Override
    public Map<String, Double> servicePayEachStatistics() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String format = sdf.format(new Date());
        String adminId = TokenManager.getToken().getAdminId();
        Map<String, Double> stringDoubleMap = this.baseMapper.servicePayEachStatisticsByZk(format);
        return stringDoubleMap;
    }
    @Override
    public Map<String, Double> servicePayEachStatisticsByAdmin() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String format = sdf.format(new Date());
        String adminId = TokenManager.getToken().getAdminId();
        Map<String, Double> stringDoubleMap = this.baseMapper.servicePayEachStatisticsByAdmin(format,adminId);
        return stringDoubleMap;
    }
}
